// template initialize() function 
// add this to project, customizing it as desired by selecting features
// to enable, then call this in main() as first thing

void initialize()      // establish PBCLK, init timer / peripheral devices
{
   picInit(SYSCLK);          

   DDPCONbits.JTAGEN = 0;   // this will disable JTAG port

   // select the desired options by deleting the // at start-of-line

   // timers for delay functions

//   delayT1_init();      // enables use of Timer1 for delay functions
//   delayT2_init();      // enables use of Timer2 for delay functions
//   delayT3_init();      // enables use of Timer3 for delay functions
//   delayT4_init();      // enables use of Timer4 for delay functions
//   delayT5_init();      // enables use of Timer5 for delay functions

	// timers for timeElapsed functions
	
//	OpenTimer23(T2_ON | T2_SOURCE_INT | T23_PRESCALER | T2_32BIT_MODE_ON, 0xFFFFFFFF);
//	OpenTimer45(T4_ON | T4_SOURCE_INT | T45_PRESCALER | T4_32BIT_MODE_ON, 0xFFFFFFFF);

	// UART device selection
	// Param1 = port #: UART1A, UART2A, UART3A, etc
	// Param2 = data rate (bps) data
	// Param3 = PBCLK
	
//	uart_Init(UART1A, 230400, PBCLK);
//	uart_Init(UART2A, 230400, PBCLK);
//	uart_Init(UART3A, 230400, PBCLK);


// setbuf() specifies no stdout buffering: all chars output immediately

	setbuf(stdout,NULL);				// specify no buffering on output
	
   // I2C devices

// 400KHz I2C Clk for PBClk of 80MHz   
#define I2CBRG 0x60
//   OpenI2C1( I2C_EN, I2CBRG );   IdleI2C1();   // Open I2C2 and wait to complete
//   OpenI2C2( I2C_EN, I2CBRG );   IdleI2C2();   // Open I2C2 and wait to complete

   // set PIC pin bank mode

//  TRISA = 0;         // all PORTA as output (0) or input (1)
//  _TRISA0 = 1;       // example of single bit A0 set as input
//  TRISB = 0;         // all PORTB as output (0) or input (1)
//  TRISC = 0;         // all PORTC as output (0) or input (1)
//  TRISD = 0;         // all PORTD as output (0) or input (1)
//  TRISE = 0;         // all PORTE as output (0) or input (1)
    
}


